import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { NgModule, Optional, SkipSelf } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { HeaderComponent } from './layout/header/header.component'; 
import { PagesModule } from './pages/pages.module';
import { BreadcrumbModule } from './share/components/breadcrumb/breadcrumb.module'; 
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { LoginComponent } from './layout/login/login.component'; 
import { CheckboxModule } from './share/components/checkbox/checkbox.module';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { DirectivesModule } from './share/directives/directives.module';
import { InterceptorService } from './services/apis/interceptor.service';
import { MessageModule } from './share/components/message/message.module';
import { PlayerComponent } from './layout/player/player.component';
import { PipesModule } from './share/pipes/pipes.module';
import { BackTopModule } from './share/components/back-top/back-top.module';
@NgModule({
  declarations: [HeaderComponent, LoginComponent, PlayerComponent],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    HttpClientModule,
    PagesModule,
    AppRoutingModule,
    BreadcrumbModule,
    DirectivesModule,
    CheckboxModule,
    FormsModule,
    ReactiveFormsModule,
    MessageModule,
    PipesModule,
    BackTopModule,
  ],
  providers: [
    { provide: HTTP_INTERCEPTORS, useClass: InterceptorService, multi: true },
  ],
  exports: [
    HeaderComponent,
    BreadcrumbModule,
    BrowserModule,
    AppRoutingModule,
    LoginComponent,
    PlayerComponent,
    BackTopModule,
  ],
})
export class CoreModule {
  constructor(@SkipSelf() @Optional() parentModule: CoreModule) {
    if (parentModule) {
      throw new Error('CoreModule只能在AppModule中引用');
    }
  }
}
